//
//  mem_item.cpp
//  JanMalloc
//
//  Created by janhit on 2022/4/16.
//

#include "MemItem.hpp"
#include "../Concurrency/TimeStamp.hpp"


namespace MMFAlloc{


MemoryItem::MemoryItem(unsigned int size, const std::thread::id& thdId)
:
mSize(size),
mThradId(thdId),
mLastAccessTime(-1)
{
    mCreateTime = MMF::TimeStamp::GetUsTime().count();
}


time_t MemoryItem::CreateTime()
{
    return mCreateTime;
}


time_t MemoryItem::LastAccessTime()
{
    return mLastAccessTime;
}


void MemoryItem::OnAccess()
{
    mLastAccessTime = MMF::TimeStamp::GetUsTime().count();
}


u32 MemoryItem::Size()
{
    return mSize;
}


void* MemoryItem::Address()
{
    return mBuff;
}


const std::thread::id& MemoryItem::ThreadId()
{
    return mThradId;
}

}
